public class BluetoothReader extends java.lang.Object implements IBluetoothReader
init(Context context) 函数初始化蓝牙相关服务,退出应用程序需要调用free()是否蓝牙相关资源init(Context context)to initiate BT service, call free() to exit application.
第二步:调用connect(java.lang.String, com.rscja.deviceapi.interfaces.ConnectionStatusCallback<java.lang.Object>)连接蓝牙,在此之前你可以调用startScanBTDevices(com.rscja.deviceapi.interfaces.ScanBTCallback)搜索附件的符合要求的蓝牙设备connect(java.lang.String, com.rscja.deviceapi.interfaces.ConnectionStatusCallback<java.lang.Object>) to connect BT, user could call startScanBTDevices(com.rscja.deviceapi.interfaces.ScanBTCallback) to search BT device nearby before connecting.| Modifier and Type | Class and Description |
|---|---|
static interface |
BluetoothReader.DecodeCallback |
static interface |
BluetoothReader.OnDataChangeListener
接收蓝牙原始数据的接口
Interface of receiving initial data. |
VERSION_BT_FIRMWARE, VERSION_BT_HARDWARE, VERSION_BT_SOFTWAREUPDATE_STM32| Modifier and Type | Method and Description |
|---|---|
boolean |
blinkOfLed(int duration,
int interval,
int count)
led 闪烁
|
boolean |
closeLed()
关闭led
|
void |
connect(java.lang.String address)
连接蓝牙(Connect Bluetooth)
|
void |
connect(java.lang.String address,
ConnectionStatusCallback<java.lang.Object> btStatusCallback)
连接蓝牙(Connect Bluetooth)
|
void |
disconnect()
断开蓝牙(Disconnect Bluetooth)
|
boolean |
free()
释放蓝牙相关的资源(free Bluetooth resources)
|
int |
getBarcodeTypeInSSIID() |
int |
getBattery()
获取电池电量
Acquire battery capacity |
int |
getBeep() |
java.lang.String |
getBleHardwareVersion() |
java.util.HashMap<java.lang.String,java.lang.String> |
getBluetoothVersion()
获取蓝牙版本号(acquire Bluetooth version)
|
ConnectionStatus |
getConnectStatus()
获取蓝牙连接状态(Acquire Bluetooth connection status)
|
static BluetoothReader |
getInstance()
Get BluetoothReader
|
byte[] |
getParameter(byte[] ssiParameter) |
java.lang.String |
getSTM32Version()
获取stm32版本号(Acquire stm32 version )
|
boolean |
init(android.content.Context context)
初始化蓝牙相关的服务(Intialize Bluetooth services)
|
boolean |
openLed()
打开led
|
java.lang.String |
scanBarcode()
扫描条码
Scan barcode |
byte[] |
scanBarcodeToBytes()
扫描条码
Scan barcode |
boolean |
sendData(byte[] sendData)
发送指令(send data)
|
boolean |
setBarcodeTypeInSSIID(boolean isContainBarcodeType) |
boolean |
setBeep(boolean isOpen)
设置蜂鸣器开关
Setup buzzer ON/OFF |
void |
setConnectionStatusCallback(ConnectionStatusCallback<java.lang.Object> btStatusCallback)
设置蓝牙连接状态的回调(Setup Bluetooth connection status call back)
|
void |
setKeyEventCallback(KeyEventCallback KeyEventCallback)
设置扫描按键回调
Setup SCAN button call back |
void |
setOnDataChangeListener(BluetoothReader.OnDataChangeListener onDataChangeListener)
设置接收蓝牙原始数据的回调函数
setup call back function for receiving BT initial data. |
boolean |
setParameter(byte[] ssiParameter,
byte[] value) |
boolean |
setRemoteBluetoothName(java.lang.String name)
修改蓝牙名称(Change Bluetooth device Name)
|
BarcodeResult |
startScanBarcode() |
void |
startScanBTDevices(ScanBTCallback scanBTCallback)
扫描蓝牙设备(scanning Bluetooth devices)
|
boolean |
stopScanBarcode() |
void |
stopScanBTDevices()
停止扫描蓝牙设备(Stop scanning Bluetooth devices)
|
boolean |
triggerBeep(int durationTime)
触发蜂鸣器(Trigger the buzzer)
|
public static BluetoothReader getInstance()
public boolean init(android.content.Context context)
IBluetoothReaderinit in interface IBluetoothReadercontext - contextpublic boolean free()
IBluetoothReaderfree in interface IBluetoothReaderpublic void startScanBTDevices(ScanBTCallback scanBTCallback)
IBluetoothReaderstartScanBTDevices in interface IBluetoothReaderscanBTCallback - 扫描结果回调(scanning result call back)public void stopScanBTDevices()
IBluetoothReaderstopScanBTDevices in interface IBluetoothReaderpublic void setConnectionStatusCallback(ConnectionStatusCallback<java.lang.Object> btStatusCallback)
IBluetoothReadersetConnectionStatusCallback in interface IBluetoothReaderbtStatusCallback - 蓝牙连接状态回调接口(Bluetooth connection status call back)public void connect(java.lang.String address,
ConnectionStatusCallback<java.lang.Object> btStatusCallback)
IBluetoothReaderconnect in interface IBluetoothReaderaddress - 蓝牙地址(Bluetooth address )btStatusCallback - 蓝牙连接状态回调接口(Bluetooth connection status call back)public void setKeyEventCallback(KeyEventCallback KeyEventCallback)
IReadersetKeyEventCallback in interface IReaderKeyEventCallback - 按键回调接口(Keyboard call back)public boolean openLed()
public boolean closeLed()
public boolean blinkOfLed(int duration,
int interval,
int count)
blinkOfLed in interface IReaderduration - 持续发光时间 范围为1-255,单位为100ms( Duration of luminescence , value:1-255 , unit:100ms )interval - 间隔时间 范围为1-255,单位为100ms (interval time, value:1-255, unit:100ms)count - 闪烁次数 1-255 (count, value:1-255)public void disconnect()
IBluetoothReaderdisconnect in interface IBluetoothReaderpublic ConnectionStatus getConnectStatus()
IBluetoothReadergetConnectStatus in interface IBluetoothReaderpublic int getBattery()
IReadergetBattery in interface IReaderpublic boolean setBeep(boolean isOpen)
IReaderpublic int getBeep()
getBeep in interface IBluetoothReaderpublic boolean triggerBeep(int durationTime)
triggerBeep in interface IReaderdurationTime - 持续时间, 范围1-255,单位为100ms (Duration, range 1-255, Unit:100ms)public java.lang.String scanBarcode()
IReaderscanBarcode in interface IReaderpublic byte[] scanBarcodeToBytes()
IReaderscanBarcodeToBytes in interface IReaderpublic boolean stopScanBarcode()
stopScanBarcode in interface IBluetoothReaderpublic boolean setBarcodeTypeInSSIID(boolean isContainBarcodeType)
setBarcodeTypeInSSIID in interface IReaderpublic int getBarcodeTypeInSSIID()
getBarcodeTypeInSSIID in interface IReaderpublic BarcodeResult startScanBarcode()
startScanBarcode in interface IReaderpublic boolean setParameter(byte[] ssiParameter,
byte[] value)
setParameter in interface IReaderpublic byte[] getParameter(byte[] ssiParameter)
getParameter in interface IReaderpublic void setOnDataChangeListener(BluetoothReader.OnDataChangeListener onDataChangeListener)
setOnDataChangeListener in interface IBluetoothReaderonDataChangeListener - OnDataChangeListenerpublic boolean sendData(byte[] sendData)
IBluetoothReadersendData in interface IBluetoothReaderpublic boolean setRemoteBluetoothName(java.lang.String name)
IBluetoothReadersetRemoteBluetoothName in interface IBluetoothReadername - 新的蓝牙名称(New Bluetooth name)public java.lang.String getSTM32Version()
IReadergetSTM32Version in interface IReaderpublic java.util.HashMap<java.lang.String,java.lang.String> getBluetoothVersion()
IBluetoothReadergetBluetoothVersion in interface IBluetoothReaderIBluetoothReader.VERSION_BT_FIRMWARE 表示固件版本(Firmware Version), key:IBluetoothReader.VERSION_BT_HARDWARE
表示硬件版本(Hardware version) , key:IBluetoothReader.VERSION_BT_SOFTWARE 表示软件版本(software version)public java.lang.String getBleHardwareVersion()
getBleHardwareVersion in interface IBluetoothReaderpublic void connect(java.lang.String address)
IBluetoothReaderconnect in interface IBluetoothReaderaddress - 蓝牙地址(Bluetooth address)